import React from 'react';
import track from 'utils/track';
import { Balloon } from '@teamix/ui';
import intl from '../../../../locale';

export default class ProjectMenu extends React.Component {
  render() {
    const { hasAccess } = this.props;
    return (
      <div className="new-repo">
        {hasAccess ? (
          <span
            onClick={() => {
              track({
                action: 'import_repo',
                page: 'Ceiling',
              });
            }}
          >
            {intl.get({
              id: 'code-assets.dialog.importProject.projectMenu.ImportCodeLibrary',
              defaultMessage: '导入代码库',
            })}
          </span>
        ) : (
          <Balloon.Tooltip
            trigger={
              <span>
                {intl.get({
                  id: 'code-assets.dialog.importProject.projectMenu.ImportCodeLibrary',
                  defaultMessage: '导入代码库',
                })}
              </span>
            }
            align="b"
            text={intl.get({
              id: 'code-assets.dialog.importProject.projectMenu.CurrentlyTheEnterpriseHasEnabled',
              defaultMessage: '当前企业开启了创建库的权限管控，如有需要请联系企业管理员修改',
            })}
          />
        )}
      </div>
    );
  }
}
